package Utils;

import java.util.ArrayList;
import java.util.List;

import app.MyApplication;
import greendao.UnitInformationDao;
import greendao.entity.ProtectMeasures;
import greendao.entity.Safety;
import greendao.entity.SecurityRisk;
import greendao.entity.UnitInformation;
import greendao.entity.User;

/**
 * Created by Ren on 2017/8/2.
 * <p>
 * 数据字典
 */

public class DictionariesUtil {

    //类别信息
    public static List<String> lb = new ArrayList<>();
    //正式日计划状态信息
    public static List<String> zt = new ArrayList<>();
    //单位信息
    public static List<UnitInformation> UnitInformation = new ArrayList<>();
    //施工单位 ljyyxDwxxType = sgdw
    public static String SGDW = "sgdw";
    public static List<UnitInformation> SgdwDictionaries = new ArrayList<>();
    //监理单位  ljyyxDwxxType = jldw
    public static String JLDW = "jldw";
    public static List<UnitInformation> JldwDictionaries = new ArrayList<>();
    //建设单位  ljyyxDwxxType =jsdw
    public static String JSDW = "jsgldw";
    public static List<UnitInformation> JsdwDictionaries = new ArrayList<>();
    //设备管理单位
    public static String SBGLDW = "sbgldw";
    public static List<UnitInformation> SbgldwDictionaries = new ArrayList<>();
    //车务站段
    public static String CWZD = "cwzd";
    public static List<UnitInformation> CwzdDictionaries = new ArrayList<>();
    //其他单位
    public static String QTDW = "qtdw";
    public static List<UnitInformation> QtdwDictionaries = new ArrayList<>();
    //机关处室 选出单位 作为审核处室
    public static String JGCS = "jgcs";
    public static List<UnitInformation> JgcsDictionaries = new ArrayList<>();

    //安全风险措施
    public static List<ProtectMeasures> ProtectMeasures = new ArrayList<>();
    //安全风险
    public static List<SecurityRisk> SecurityRisk = new ArrayList<>();
    //施工安全问题分类字典表
    public static List<Safety> Safety = new ArrayList<>();
    //本单位用户信息
    public static List<User> UnitUser = new ArrayList<>();


    static {
        lb.add("B");
        lb.add("C");

        zt.add("已下达");
        zt.add("已作废");
        zt.add("可作废");
    }

    //本单位用户信息
    public static List getUnitUserList() {
        if (UnitUser.size() == 0) {
            UnitUser = MyApplication.getDaoSession().getUserDao().loadAll();
        }
        return UnitUser;
    }

    //施工安全问题分类字典表
    public static List getSafetyList() {
        if (Safety.size() == 0) {
            Safety = MyApplication.getDaoSession().getSafetyDao().loadAll();
        }
        return Safety;
    }

    //安全风险
    public static List getSecurityRiskList() {
        if (SecurityRisk.size() == 0) {
            SecurityRisk = MyApplication.getDaoSession().getSecurityRiskDao().loadAll();
        }
        return SecurityRisk;
    }

    //安全风险措施
    public static List getProtectMeasuresList() {
        if (ProtectMeasures.size() == 0) {
            ProtectMeasures = MyApplication.getDaoSession().getProtectMeasuresDao().loadAll();
        }
        return ProtectMeasures;
    }

    //机关处室 选出单位 作为审核处室
    public static List getJgcsUnitList() {
        if (JgcsDictionaries.size() == 0) {
            JgcsDictionaries = MyApplication.getDaoSession().getUnitInformationDao().queryBuilder()
                    .where(UnitInformationDao.Properties.LjyyxDwxxType.like("%" + DictionariesUtil.JGCS + "%")).list();
        }
        return JgcsDictionaries;
    }

    //其他单位
    public static List getQtdwUnitList() {
        if (QtdwDictionaries.size() == 0) {
            QtdwDictionaries = MyApplication.getDaoSession().getUnitInformationDao().queryBuilder()
                    .where(UnitInformationDao.Properties.LjyyxDwxxType.like("%" + DictionariesUtil.QTDW + "%")).list();
        }
        return QtdwDictionaries;
    }

    //车务站段
    public static List getCwzdUnitList() {
        if (CwzdDictionaries.size() == 0) {
            CwzdDictionaries = MyApplication.getDaoSession().getUnitInformationDao().queryBuilder()
                    .where(UnitInformationDao.Properties.LjyyxDwxxType.like("%" + DictionariesUtil.CWZD + "%")).list();
        }
        return CwzdDictionaries;
    }

    //设备管理单位
    public static List getSbgldwUnitList() {
        if (SbgldwDictionaries.size() == 0) {
            SbgldwDictionaries = MyApplication.getDaoSession().getUnitInformationDao().queryBuilder()
                    .where(UnitInformationDao.Properties.LjyyxDwxxType.like("%" + DictionariesUtil.SBGLDW + "%")).list();
        }
        return SbgldwDictionaries;
    }

    //建设单位
    public static List getJsdwUnitList() {
        if (JsdwDictionaries.size() == 0) {
            JsdwDictionaries = MyApplication.getDaoSession().getUnitInformationDao().queryBuilder()
                    .where(UnitInformationDao.Properties.LjyyxDwxxType.like("%" + DictionariesUtil.JSDW + "%")).list();
        }
        return JsdwDictionaries;
    }

    //监理单位
    public static List getJldwUnitList() {
        if (JldwDictionaries.size() == 0) {
            JldwDictionaries = MyApplication.getDaoSession().getUnitInformationDao().queryBuilder()
                    .where(UnitInformationDao.Properties.LjyyxDwxxType.like("%" + DictionariesUtil.JLDW + "%")).list();
        }
        return JldwDictionaries;
    }

    //施工单位
    public static List getSgdwUnitList() {
        if (SgdwDictionaries.size() == 0) {
            SgdwDictionaries = MyApplication.getDaoSession().getUnitInformationDao().queryBuilder()
                    .where(UnitInformationDao.Properties.LjyyxDwxxType.like("%" + DictionariesUtil.SGDW + "%")).list();
        }
        return SgdwDictionaries;
    }

    //单位信息
    public static List getUnitList() {
        if (UnitInformation.size() == 0) {
            UnitInformation = MyApplication.getDaoSession().getUnitInformationDao().loadAll();
        }
        return UnitInformation;
    }

}
